// web/src/app/(employee)/meet/_components/chat-input.tsx
'use client';
import dynamic from "next/dynamic";
import {useRouter} from "next/navigation";
import {useCurrentUser} from "@/hooks/use-current-user";
import React, {useRef, useState} from "react";
import Quill from "quill";
import {toast} from "sonner";

const Editor = dynamic(() =>
    import('@/components/social/editor'), {ssr: false}
);

interface Props {
    placeholder: string
    handleSubmit?: Function
}

type CreateMessageValues = {
    channelId: string
    userId: string
    workspaceId: string
    body: string
    image: string
}

const ChatInput = ({placeholder, handleSubmit}: Props) => {
    const router = useRouter()
    const user = useCurrentUser()

    const editorRef = useRef<Quill | null>(null)
    const [editorKey, setEditorKey] = useState(0)
    const [isPending, setIsPending] = useState(false)

    return (
        <div className={`px-5 w-full`}>
            <Editor
                key={editorKey}
                // variant={'update'}
                placeholder={placeholder}
                // @ts-ignore
                onSubmit={handleSubmit}
                disabled={isPending}
                innerRef={editorRef}
            />
        </div>
    );
};

export default ChatInput;